package com.sny.constants;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * @Author: Administrator
 * @Description: 统一返回实体 Amis
 * @Date: 2020-05-22 15:26
 */
@Data
@Slf4j
public class ResultForAmis<T> implements Serializable {

    private static final long serialVersionUID = -4482919136772742121L;
    /**
     * 返回status
     */
    private Integer status;
    /**
     * 返回信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private T data;

    public ResultForAmis() {
    }

    public ResultForAmis(T data) {
        this.status = 0;
        this.msg = "ok";
        this.data = data;
    }

    public ResultForAmis(Integer status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public ResultForAmis(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    /**
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis fail() {
        return new ResultForAmis(999999, "fail");
    }


    /**
     * @param msg 失败提示
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis fail(String msg) {
        return new ResultForAmis(999999, msg);
    }

    /**
     * @param e 失败枚举
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
//    public static ResultForAmis fail(BusinessEnums e) {
//        return new ResultForAmis(e.getCode(), e.getMsg());
//    }

    /**
     * @param msg  失败提示
     * @param data 失败返回实体
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
//    public static Result fail(String msg, Object data) {
//        return new Result(BusinessEnums.FAIL.getCode(), msg, data);
//    }

    /**
     * @param status 失败code码
     * @param msg    失败提示
     * @param data   失败返回实体
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
//    public static Result fail(Integer status, String msg, Object data) {
//        return new Result(status, msg, data);
//    }

    /**
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 成功时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis success() {
        return new ResultForAmis(0, "ok", null);
    }

    /**
     * @param msg 成功提示
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 成功时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis success(String msg) {
        return new ResultForAmis(0, msg, null);
    }

    /**
     * @param e 成功枚举
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 失败时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
//    public static Result success(BusinessEnums e) {
//        return new Result(e.getCode(), e.getMsg(), null);
//    }

    /**
     * @param msg  成功提示
     * @param data 成功实体
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 成功时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis success(String msg, Object data) {
        return new ResultForAmis(0, msg, data);
    }

    /**
     * @param status 成功code码
     * @param msg    成功提示
     * @param data   成功实体
     * @return com.dcits.springbootsingle.constants.Result
     * @throws
     * @Description: 成功时返回结构
     * @Author: Administrator
     * @Date: 2020/5/22
     */
    public static ResultForAmis success(Integer status, String msg, Object data) {
        return new ResultForAmis(status, msg, data);
    }

    /**
     * @param data 返回结果
     * @return com.dcits.constants.Result
     * @throws
     * @Description: 成功时返回结构
     * @Author: Administrator
     * @Date: 2020/5/25
     */
    public static ResultForAmis success(Object data) {
        return new ResultForAmis(0, "ok", data);
    }
}
